import { postForm, get, put } from '@/utils/request'

// 获取列表
export function getRecords(listQuery) {
  return get('/job/list/page', listQuery)
}

export function add(optData) {
  return postForm('/job', optData)
}

export function edit(optData) {
  return put('/job', optData)
}

export function del(ids) {
  return postForm('/job/del/batch', { pkIds: JSON.stringify(ids) })
}

// 启动
export function runJob(jobId) {
  return get('/job/run', { jobId: jobId })
}

// 重启
export function resumeJob(jobId) {
  return get('/job/resume', { jobId: jobId })
}

// 暂停
export function pauseJob(jobId) {
  return get('/job/pause', { jobId: jobId })
}

// 替换Cron
export function upCron(jobId, cron) {
  return get('/job/upt/cron', { jobId: jobId, cronExpression: cron })
}

export default { add, edit, del }
